package com.informaticafeminale.db.server;

import java.io.IOException;
import java.sql.SQLException;

import org.h2.tools.Server;

import com.informaticaFeminale2011.interfaces.Settings;

public class TcpServer {

	private static String[] ARGS = { "-tcpShutdown",
			"tcp://localhost:" + Settings.PORT };

	public void run(String[] args) throws SQLException, IOException {
		Server srv = Server.createTcpServer(args).start();
		boolean bo = true;
		while (bo) {
			System.in.read();
			bo = false;
		}
		srv.stop();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.println("DB Server starts with the following data ....");
		TcpServer sr = new TcpServer();
		for (String s : ARGS)
			System.out.print("'" + s + "'\n");
		System.out
				.println("DB Server stops in case you type in some character.");
		try {
			sr.run(ARGS);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("CU sooooooooooooooooooonnnnnnnnnnnn");
	}
}
